// SPDX-License-Identifier: GPL-2.0

#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt

#include <linux/init.h>
#include <linux/module.h>
#include <linux/moduleparam.h>

#include "dim_monitor_measure.h"

extern struct dentry *dim_root;

MODULE_LICENSE("GPL");

static char *algo;
module_param(algo, charp, 0);

static int __init dim_monitor_init(void)
{
	int ret;

	if (dim_root == NULL) {
		pr_info("dim monitor off\n");
		return 0;
	}

	ret = dim_monitor_prepare(algo);
	if (ret != 0)
		return ret;

	pr_info("dim monitor on\n");
	return ret;
}

static void __exit dim_monitor_exit(void)
{
	dim_monitor_finish();
}

#if IS_BUILTIN(CONFIG_EULEROS_DIM_MONITOR)
late_initcall(dim_monitor_init);
#elif IS_MODULE(CONFIG_EULEROS_DIM_MONITOR)
module_init(dim_monitor_init);
#endif
module_exit(dim_monitor_exit);
